<template>
  <a-modal
    title="打印"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
  >
  <template slot="footer">
        <a-button key="back" @click="handleCancel">
          取消
        </a-button>
        <a-button key="submit" type="primary"  @click="handleSubmit">
          打印
        </a-button>
  </template>
  <div class="print" ref="print">
    <div class="main-content">
      <h2 class="zkxx">租客信息</h2>
      <a-row class="main-content-item">
        <a-col :span="24" class="ydxx">
          <h4>{{ form.name }}<span class="phone">{{ form.phone }}</span></h4>
          <h4 v-for="(item,index) in form.leaseLiveData" :key="index">
            {{ item.name }}<span class="phone">{{ item.phone }}</span>
          </h4>
          <h4>{{ form.roomName }}</h4>
          <h4>租期: {{ form.rentStartDate }}~{{ form.rentEndDate }}</h4>
          <h4>{{ form.receiptCycle }}</h4>
          <h4>租金: {{ form.rent }}元/月</h4>
          <h4>房屋押金: {{ form.deposit }}元</h4>
          <h4>賬單起始日: 起租日</h4>
        </a-col>
      </a-row>
    </div>
  </div>
  </a-modal>
</template>

<script>
  import { getIsLeaseMsgPrint } from '@/api/modular/main/houselease/houseLeaseManage'
  import moment from 'moment'
  export default {
    data () {
      return {
        visible: false,
        confirmLoading: false,
        form: {}
      }
    },
    methods: {
      moment,
      // 初始化方法
      edit (record) {
        this.visible = true
        this.getData(record)
      },
      getData (id) {
        getIsLeaseMsgPrint(id).then((res) => {
          if (res.code === 200) {
            this.form = res.data
          } else {
            this.$message.error('查詢失敗')//  + res.message
          }
        })
      },
      handleSubmit () {
        this.$print(this.$refs.print) // 使用
        this.handleCancel()
      },
      handleCancel () {
        this.visible = false
      }
    }
  }
</script>
<style scoped>
.print{
  padding: 6px 10px;
}
.title{
  text-align: center;
  tab-size: 20px;
}
.item-end{
  float: right;
}
.main-content{
  margin-top: 10px;
  margin-bottom: 10px;
  border: solid 1px rgb(218, 211, 211);
}
.dj{
  border-bottom: solid 1px rgb(218, 211, 211);
}
.main-content-item{
  padding: 10px;
}
.zkxx{
  margin: 6px 0px 6px 6px;
}
.divider-content-only{
    font-size: 20px;
    margin-bottom: 10px;
  }
  .divider-content-center-only{
      margin-top: 10px;
  }
  .span-calculateStyle{
    font-size: 14px;
    margin-bottom: 20px;
  }
.phone{
  margin-left: 40px;
}
</style>
